//
//  FirstTableViewCell.m
//  UI23_Work ali
//
//  Created by dllo on 16/8/15.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "FirstTableViewCell.h"
#import "MyCollectionViewCell.h"
#define kCollectionView @"collectReuse"
#import "DetailViewController.h"

@interface FirstTableViewCell () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;

@end

@implementation FirstTableViewCell

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (self.array.count == 3) {
        return CGSizeMake((collectionView.bounds.size.width - 20) / 3, collectionView.bounds.size.height- 10);
    } else {
        return CGSizeMake((self.bounds.size.width - 30) / 3, (self.bounds.size.height- 30) / 2);
    }
}
- (void)setArray:(NSArray<SecData *> *)array {
    _array = array;
    [_myCollectionView reloadData];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
        return self.array.count;
}



- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionView forIndexPath:indexPath];
    cell.sec = self.array[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
